import React, { Component } from 'react'
import { Row, Col, Input, Button, Radio } from "antd"
export default class StudentSearchBar extends Component {
    constructor(props) {
        super(props);
        const def = {
            key: "",
            sex: -1
        }
        this.state = Object.assign({}, def, this.props.defaultValue)
    }
    handleRadioChange = e => {
        this.setState({
            sex: +e.target.value
        })
    }
    handleSearch = () => {
        if (this.props.onSearch) {
            this.props.onSearch(this.state)
        }
    }
    render() {
        return (
            <div>
                <Row type="flex" justify="start" gutter={10}>
                    <Col>
                        <Input addonBefore="关键字" value={this.state.key} onChange={e => {
                            this.setState({
                                key: e.target.value
                            })
                        }} />
                    </Col>
                        <Button type="link"
                            style={{
                                paddingRight:0
                            }}
                        >性别:</Button>
                    <Col>
                    </Col>
                    <Col>
                        <Radio.Group onChange={this.handleRadioChange} defaultValue="-1">
                            <Radio.Button checked={this.state.sex === -1} value={-1}>不限</Radio.Button>
                            <Radio.Button checked={this.state.sex === 0} value={0}>男</Radio.Button>
                            <Radio.Button checked={this.state.sex === 1} value={1}>女</Radio.Button>
                        </Radio.Group>
                        
                    </Col>
                    <Col><Button onClick={this.handleSearch} type="primary">查询</Button></Col>
                </Row>

            </div>
        )
    }
}
